#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : @time
# @Author  : yaojc
# @Email   : aaaaaayaojunchao@163.com
# @File    : get_api.py
# @Software: File
 
class Dict2Obj(dict): 
	# 字典转对象
    def __getattr__(self, key):
        value = self.get(key,None)
        return value if not isinstance(value, dict) else Dict2Obj(value)
class test():
    m = 0
    def __new__(cls,*args, **kraws):
      
        return object.__new__(cls) 
    def __init__(self):
        print('init')
        super().__init__()
    # @classmethod
    def createObj(self):
        print(self.m)
        if self.m == 0:
            print('对象不存在，开始创建')
            self.m += 1
        else:
            print('对象已存在，开始创建')
if __name__ == "__main__":
    a = test()
    a.createObj()
    print(id(a))
    a = test()
    a.createObj()
    print(id(a))

# if __name__ == "__main__":
#     dict1 = {'key':'value'}
#     dictObj = Dict2Obj(dict1)

#     print('值：', dictObj.key)
#     print('zhi', dictObj['key'])

#     print('id: ', id(dictObj))
#     print('type:', type(dictObj))
#     print('全部打印', dictObj)
